home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / J_AUTHOR / Mojo / data.2 / docs / microline / examples / grid2.java < prev    next >
Encoding:
Java Source  |  1996-05-27  |  6.2 KB  |  189 lines

  1. // (c) Copyright 1994-1996 Microline Software, Inc. ALL RIGHTS RESERVED
  2. //
  3. // THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE COPIED AND USED
  4. // ONLY IN ACCORDANCE WITH THE TERMS OF THAT LICENSE AND WITH THE INCLUSION
  5. // OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE AND DOCUMENTATION, AND ITS
  6. // COPYRIGHTS ARE OWNED BY MICROLINE SOFTWARE AND ARE PROTECTED BY UNITED
  7. // STATES COPYRIGHT LAWS AND INTERNATIONAL TREATY PROVISIONS.
  8. //
  9. // THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
  10. // AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY MICROLINE SOFTWARE.
  11. //
  12. // THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT
  13. // WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY
  14. // PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT.  MICROLINE SOFTWARE
  15. // ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS
  16. // SOFTWARE.
  17. //
  18. // MICROLINE SOFTWARE SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR
  19. // CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SOME
  20. // STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
  21. // CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATIONS MIGHT NOT APPLY TO
  22. // YOU.
  23. //
  24. // MICROLINE SOFTWARE SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE
  25. // ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES
  26. // RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE
  27. // TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY
  28. // MICROLINE SOFTWARE.
  29. //
  30. // U.S. GOVERNMENT RESTRICTED RIGHTS
  31. // This Software and documentation are provided with RESTRICTED RIGHTS.
  32. // Use, duplication or disclosure by the Government is subject to
  33. // restrictions as set forth in subparagraph (c)(1) of the Rights in
  34. // Technical Data and Computer Software Clause at DFARS 252.227-7013 or
  35. // subparagraphs (c)(1)(ii) and (2) of Commercial Computer Software -
  36. // Restricted Rights at 48 CFR 52.227-19, as applicable, supplier is
  37. // Microline Software, 41 Sutter St Suite 1374, San Francisco, CA 94104.
  38.  
  39. import java.awt.*;
  40. import java.mct.*;
  41. import java.applet.Applet;
  42.  
  43. public class grid2 extends Applet
  44. {
  45. MlGrid grid;
  46. Image upArrow, downArrow;
  47.  
  48. public void init()
  49.     {
  50.     MlResources res;
  51.  
  52.     setLayout(new BorderLayout());
  53.  
  54.     makeIcons();
  55.  
  56.     res = new MlResources();
  57.  
  58.     grid = new MlGrid();
  59.  
  60.     grid.setValue("layoutFrozen", true);
  61.  
  62.     res.add("allowColumnResize", true);
  63.     res.add("selectionPolicy", "SELECT_MULTIPLE_ROW");
  64.     res.add("headingRows", 1);
  65.     res.add("columns", 7);
  66.     res.add("simpleWidths", "18c 8c 16p 8c 12c 16c 6c");
  67.     res.add("rightFixedCount", 1);
  68.     res.add("leftFixedCount", 1);
  69.     res.add("simpleHeadings", "Name|Price||Change|Close Date|Location|Yield");
  70.     grid.setValues(res);
  71.  
  72.     // set defaults for content cells
  73.     res.clear();
  74.     res.add("cellDefaults", true);
  75.     res.add("cellBackground", "#ffffff");
  76.     res.add("cellLeftBorderType", "BORDER_NONE");
  77.     res.add("cellRightBorderType", "BORDER_NONE");
  78.     res.add("cellTopBorderType", "BORDER_NONE");
  79.     res.add("cellBottomBorderType", "BORDER_NONE");
  80.     grid.setValues(res);
  81.  
  82.     res.clear();
  83.     res.add("rowType", "HEADING");
  84.     res.add("column", 1);
  85.     res.add("cellColumnSpan", 1);
  86.     grid.setValues(res);
  87.  
  88.     res.clear();
  89.     res.add("cellDefaults", true);
  90.     res.add("cellAlignment", "ALIGNMENT_RIGHT");
  91.     grid.setValues(res);
  92.  
  93.     res.clear();
  94.     res.add("cellDefaults", true);
  95.     res.add("column", 0);
  96.     res.add("cellAlignment", "ALIGNMENT_LEFT");
  97.     grid.setValues(res);
  98.  
  99.     res.clear();
  100.     res.add("cellDefaults", true);
  101.     res.add("column", 1);
  102.     res.add("cellRightBorderType", "BORDER_NONE");
  103.     grid.setValues(res);
  104.  
  105.     res.clear();
  106.     res.add("cellDefaults", true);
  107.     res.add("column", 2);
  108.     res.add("cellType", "IMAGE_CELL");
  109.     res.add("cellLeftBorderType", "BORDER_NONE");
  110.     grid.setValues(res);
  111.  
  112.     grid.addRows(10);
  113.  
  114.     grid.setStrings(0, "TZZ 3.0 Tana Zin|102.23||-1.2|1/1/94|Tomano, RE|5.6%");
  115.     grid.setStrings(1, "BLC 4.5 Board L|103.23||+2.5|2/15/94|Rino, LO|6.8%");
  116.     grid.setStrings(2, "DGB 5.4 Dig Gen|101.53||+3.7|6/20/94|Carolana, CA|7.5%");
  117.     grid.setStrings(3, "KLC 5.3 Kord L|108.98||-2.5|2/15/94|Cannes, CA|8.7%");
  118.     grid.setStrings(4, "LLO 3.4 Liw Lol|107.24||+2.2|2/20/94|Tenise, MI|6.7%");
  119.     grid.setStrings(5, "MMN 3.1 Mon Mor|105.63||+1.4|2/15/94|Waterton, MN|6.3%");
  120.     grid.setStrings(6, "PLP 4.3 Pol Lab|102.12||-2.3|2/20/94|Holard, LM|7.6%");
  121.     grid.setStrings(7, "SZN 4.5 Siml Zi|101.11||+1.6|2/15/94|Tempest, CA|5.4%");
  122.     grid.setStrings(8, "TTL 5.6 Towa Tin|101.12||+2.7|3/15/94|Conila, OK|6.7%");
  123.     grid.setStrings(9, "ULD 5.4 Upl La D|105.12||-2.2|4/15/94|Mandrill, HI|7.8%");
  124.  
  125.  
  126.     res.clear();
  127.     res.add("column", 2);
  128.     res.add("cellImage", upArrow);
  129.     grid.setValues(res);
  130.  
  131.     res.clear();
  132.     res.add("column", 2);
  133.     res.add("rowStep", 3);
  134.     res.add("cellImage", downArrow);
  135.     grid.setValues(res);
  136.  
  137.     grid.setValue("layoutFrozen", false);
  138.  
  139.     add("Center", grid);
  140.     }
  141.  
  142. public void makeIcons()
  143.     {
  144.     MlIconMaker im;
  145.  
  146.        im = new MlIconMaker();
  147.     im.setDimensions(12, 16);
  148.     im.setColor('G', 0xff008000);
  149.     im.setColor('R', 0xff800000);
  150.  
  151.     im.setPixels("            ");
  152.     im.setPixels("     GG     ");
  153.     im.setPixels("    GGGG    ");
  154.     im.setPixels("   GGGGGG   ");
  155.     im.setPixels("  GGGGGGGG  ");
  156.     im.setPixels(" GGGGGGGGGG ");
  157.     im.setPixels(" GGGGGGGGGG ");
  158.     im.setPixels(" GG GGGG GG ");
  159.     im.setPixels(" G  GGGG  G ");
  160.     im.setPixels("    GGGG    ");
  161.     im.setPixels("    GGGG    ");
  162.     im.setPixels("    GGGG    ");
  163.     im.setPixels("    GGGG    ");
  164.     im.setPixels("    GGGG    ");
  165.     im.setPixels("    GGGG    ");
  166.     im.setPixels("            ");
  167.     upArrow = im.createImage(this);
  168.  
  169.     im.clear();
  170.     im.setPixels("            ");
  171.     im.setPixels("    RRRR    ");
  172.     im.setPixels("    RRRR    ");
  173.     im.setPixels("    RRRR    ");
  174.     im.setPixels("    RRRR    ");
  175.     im.setPixels("    RRRR    ");
  176.     im.setPixels("    RRRR    ");
  177.     im.setPixels(" R  RRRR  R ");
  178.     im.setPixels(" RR RRRR RR ");
  179.     im.setPixels(" RRRRRRRRRR ");
  180.     im.setPixels(" RRRRRRRRRR ");
  181.     im.setPixels("  RRRRRRRR  ");
  182.     im.setPixels("   RRRRRR   ");
  183.     im.setPixels("    RRRR    ");
  184.     im.setPixels("     RR     ");
  185.     im.setPixels("            ");
  186.     downArrow = im.createImage(this);
  187.     }
  188. }
  189.